<?php 
namespace app\index\controller;
use think\Controller;
use app\index\wechat\Wechat as WC;

class Wechat extends Controller{
	private $wc;
	public function __construct(){
		$this->wc=new WC();
	}
	function index(){
		if(input('get.echostr')){
			echo $this->wc->valid();
		}else{//消息响应
			$this->wc->receiveMsg();
		}
	}


	function test(){
		$o=new \stdClass();
		$o->FromUserName='o-1ZVwxFIx2-NuXwfzFyi8JzLzZQ';
		$o->ToUserName='bbb';
		$res=$this->wc->sendTemplate($o,'JQ7nNvUX70ZJt53JggLnXiSWwG4b9ahjxCHRRINW4rM');
		p($res);
	}
	function getat(){
		$arr=[
					[
					'Title'=>'李冰冰',
					'Description'=>'国际影星',
					'PicUrl'=>'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487697586179&di=ed2562d91e6dc3ec258323718bfe83c4&imgtype=0&src=http%3A%2F%2Fimg.bimg.126.net%2Fphoto%2FAYNvS4vA2A-bEWHlCRXQNg%3D%3D%2F3722225092038531448.jpg',
					'Url'=>'http://www.jzcoder.com',
					],
					[
					'Title'=>'李冰冰2',
					'Description'=>'国际影星fda',
					'PicUrl'=>'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487698238073&di=c1a98dff139745120dcb330ab195871a&imgtype=0&src=http%3A%2F%2Fimg457.ph.126.net%2F-cH_fsW6Yd6BSaKfCkDrXA%3D%3D%2F1575415444650233776.jpg',
					'Url'=>'http://www.ittaoli.com',
					],
				];
			$xml='<xml>
			<ToUserName><![CDATA[aaa]]></ToUserName>
			<FromUserName><![CDATA[bbb]]></FromUserName>
			<CreateTime>'.time().'</CreateTime>
			<MsgType><![CDATA[news]]></MsgType>
			<ArticleCount>'.count($arr).'</ArticleCount>
			<Articles>';
		for($i=0;$i<count($arr);$i++){
			$xml.='<item>
			<Title><![CDATA['.$arr[$i]['Title'].']]></Title> 
			<Description><![CDATA['.$arr[$i]['Description'].']]></Description>
			<PicUrl><![CDATA['.$arr[$i]['PicUrl'].']]></PicUrl>
			<Url><![CDATA['.$arr[$i]['Url'].']]></Url>
			</item>';
		}

		$xml.='</Articles>
			</xml> ';
			echo $xml;
	}


}